package com.bocloud.cmp.driver.providers.ali;

import org.springframework.util.StringUtils;

import com.bocloud.cmp.driver.providers.AuthDriver;
import com.bocloud.cmp.driver.providers.LocationDriver;
import com.bocloud.common.model.BsmResult;

public class AliAuthDriver extends AliDriver implements AuthDriver {

	/**
	 * 
	 */
	public AliAuthDriver() {
		super();
	}

	/**
	 * @param accessKey
	 * @param secretKey
	 * @param regionId
	 */
	public AliAuthDriver(String accessKey, String secretKey, String regionId) {
		super(accessKey, secretKey, regionId);
	}

	@Override
	public BsmResult auth() {
		if (StringUtils.isEmpty(getRegionId())) {
			setRegionId("cn-hangzhou");
		}
		LocationDriver driver = new AliLocationDriver(this.getAccessKey(), this.getSecretKey(), this.getRegionId());
		BsmResult result = driver.listRegions();
		result = new BsmResult(result.isSuccess(), "" + result.isSuccess());
		return result;
	}

}
